package etnorservice.etnor_service.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import etnorservice.etnor_service.domain.MenuItemDomain;
import etnorservice.etnor_service.domain.po.MenuItem;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * @Author: cc
 * @Date: 2024/10/17/13:12
 *
 **/
@Mapper
public interface MenuMapper extends BaseMapper<MenuItemDomain> {
    //查找顶层菜单
    List<MenuItem> findAllNodeMenu();
    //查找子菜单
    List<MenuItem> findChirendNode(@Param("id") String id);
    List<MenuItemDomain> getMenuTree();
    // 获取角色的所有权限
    List<MenuItemDomain> getRolePermissions(@Param("roleId") Integer roleId);

    // 获取所有权限
    List<MenuItemDomain> getAllPermissions();

    // 根据父ID删除菜单
    void deleteByParentId(@Param("id") Integer id);

    // 新增：根据角色ID获取已分配的权限ID列表
    List<Integer> getAssignedPermissionIds(@Param("roleId") Integer roleId);

    // 新增：获取指定ID的所有子权限
    List<MenuItemDomain> getChildrenPermissions(@Param("parentId") Integer parentId);

}
